﻿IF OBJECT_ID ('dbo.md5') IS NOT NULL
    DROP FUNCTION dbo.md5;
GO

CREATE FUNCTION dbo.md5 (@data VARCHAR(4096)) 
RETURNS CHAR(32) AS
BEGIN
	RETURN SUBSTRING(MASTER.dbo.fn_varbintohexstr(HASHBYTES('MD5', @data)), 3, 32)
END
GO